#include <iostream>
#include <queue>
#include <string>

using namespace std;

//队列 Queue
class Person
{
    public:
        Person(string name, int age)
        {
            this->m_Name = name;
            this->m_Age = age;
        }
        string m_Name;
        int m_Age;
};

void test01()
{
    //创建队列
    queue<Person>q;

    //准备数据
    Person p1("小明", 10);
    Person p2("小红", 9);
    Person p3("张三", 20);
    Person p4("李四", 18);

    //入队
    q.push(p1);
    q.push(p2);
    q.push(p3);
    q.push(p4);

    cout << "队列大小为：" << q.size() << endl;
    cout << endl;

    //判断只要队列不为空，查看对头，查看队尾，出对
    while (!q.empty())
    {
        //查看对头
        cout << "对头元素 -- 姓名：" << q.front().m_Name << " 年龄：" << q.front().m_Age << endl;

        //查看队尾
        cout << "队尾元素 -- 姓名：" << q.back().m_Name << " 年龄：" << q.back().m_Age << endl;

        //出对
        q.pop();  //出队是出对头元素

        cout << endl;
    }
    cout << "队列大小为：" << q.size() << endl;
}

int main() 
{
    test01();

    return 0;

}
